<?php

class Category extends Controller{

	public $useDB = "Category";

	public function show($category_id, $category_name="", $page=1){
		$category = $this->dbCategory->get($category_id);
		$this->set("category", $category);
		$this->dbLoad("Product");

		list($products, $total) = $this->dbProduct->search($category["id"], $page, PRODUCTS_PER_PAGE);
		$this->set("products", $products);
		$this->set("total", $total);
		$this->set("page", $page);

	}
	private function filter_to($category_name){
		$filter = $this->getFilter();
		if($filter){
			foreach(array_reverse($filter) as $type=>$data){
				if($category_name == $type){
					break;
				}
				$this->clearFilter($type);
			}
		}
	}

	public function unset_filter($tag){
		$this->autoRender = false;
		if($tag){
			echo $tag;
			$this->clearFilter($tag);
		}
	}

}

?>